// -----------文章请求模块------------

// 加载服务器请求的方法
import request from '@/utils/request'

// 导出文章列表请求的方法
export const getArticles = params => {
  return request({
    method: 'GET',
    url: '/app/v1_1/articles',
    params
  })
}

// 导出文章详情请求的方法
export const getArticleById = articleId => {
  return request({
    method: 'GET',
    url: `/app/v1_0/articles/${articleId}`
  })
}

// 导出收藏文章请求的方法
export const addCollect = target => {
  return request({
    method: 'POST',
    url: `/app/v1_0/article/collections`,
    data: {
      target
    }
  })
}

// 导出取消收藏文章请求的方法
export const deleteCollect = target => {
  return request({
    method: 'DELETE',
    url: `/app/v1_0/article/collections/${target}`
  })
}

// 导出文章点赞请求的方法
export const addLike = target => {
  return request({
    method: 'POST',
    url: `/app/v1_0/article/likings`,
    data: {
      target
    }
  })
}

// 导出取消点赞请求的方法
export const deleteLike = target => {
  return request({
    method: 'DELETE',
    url: `/app/v1_0/article/likings/${target}`
  })
}
